//
//  LGPatientSportsSendCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/8/9.
//

#import "LGPatientSportsSendCell.h"

@interface LGPatientSportsSendCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;
/**   */
@property (nonatomic , strong)UILabel *timeTitle;
/**   */
@property (nonatomic , strong)UILabel *timeLabel;
/**   */
@property (nonatomic , strong)UILabel *rateTitle;
/**   */
@property (nonatomic , strong)UILabel *rateLabel;

@end

@implementation LGPatientSportsSendCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.titleLabel.text = LGNSString(dataDic[@"title"]);
//    self.contentLabel.text = LGNSString(dataDic[@"description"]);
    self.timeLabel.text = [NSString stringWithFormat:@"%@ 分钟",dataDic[@"duration"]];
    self.rateLabel.text = LGNSString(dataDic[@"frequency"]);
    NSString *content = @"";
    NSArray *itemArray = dataDic[@"actions"];
    for (NSInteger i=0; i<itemArray.count; i++) {
        NSDictionary *tempDic = itemArray[i];
        NSString *tempStr = [NSString stringWithFormat:@"%@·%@",tempDic[@"category_name"],tempDic[@"title"]];
        content = (content.length>0)?[NSString stringWithFormat:@"%@、%@",content,tempStr]:tempStr;
    }
    self.contentLabel.text = content;
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.contentView.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
    [self.contentView addSubview:self.baseView];
    [self.baseView addSubview:self.selectBtn];
    [self.baseView addSubview:self.titleLabel];
    [self.baseView addSubview:self.contentLabel];
    [self.baseView addSubview:self.timeTitle];
    [self.baseView addSubview:self.timeLabel];
    [self.baseView addSubview:self.rateTitle];
    [self.baseView addSubview:self.rateLabel];
    [self.selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView).offset(viewPix(11));
        make.width.height.equalTo(@(viewPix(24)));
        make.centerY.equalTo(self.baseView);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.baseView).offset(viewPix(15));
        make.left.equalTo(self.baseView).offset(viewPix(48));
        make.right.equalTo(self.baseView).offset(-viewPix(10));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(viewPix(8));
        make.left.right.equalTo(self.titleLabel);
    }];
    [self.timeTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentLabel.mas_bottom).offset(viewPix(10));
        make.left.equalTo(self.titleLabel);
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.timeTitle.mas_right).offset(viewPix(7));
        make.centerY.equalTo(self.timeTitle);
    }];
    
    [self.rateTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView).offset(viewPix(160));
        make.width.equalTo(@(37));
        make.centerY.equalTo(self.timeTitle);
    }];
    [self.rateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.rateTitle.mas_right).offset(viewPix(4));
        make.centerY.equalTo(self.timeTitle);
        make.right.equalTo(self.baseView).offset(-viewPix(3));
    }];
    
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:15];
        _baseView.frame = CGRectMake(viewPix(15), viewPix(8), Screen_W-viewPix(28), viewPix(110));
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UIButton *)selectBtn{
    if(!_selectBtn){
        _selectBtn = [UIButton buttonWithImage:@"unselect24" selectImage:@"selected24"];
        _selectBtn.userInteractionEnabled = NO;
    }
    return _selectBtn;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _titleLabel;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"" colorString:@"#999999" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _contentLabel;
}

-(UILabel *)timeTitle{
    if(!_timeTitle){
        _timeTitle = [UILabel lableWithText:@"时长" colorString:@"#999999" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _timeTitle;
}

-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _timeLabel;
}

-(UILabel *)rateTitle{
    if(!_rateTitle){
        _rateTitle = [UILabel lableWithText:@"频率" colorString:@"#999999" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _rateTitle;
}

-(UILabel *)rateLabel{
    if(!_rateLabel){
        _rateLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _rateLabel;
}






- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
